import random
import numpy as np

def generate_random_array(size, min_val=0, max_val=10000):
    """Generate a random array of given size with values between min_val and max_val"""
    return [random.randint(min_val, max_val) for _ in range(size)]

def generate_sorted_array(size, ascending=True):
    """Generate a sorted array (either ascending or descending)"""
    arr = list(range(size))
    return arr if ascending else arr[::-1]

def generate_nearly_sorted_array(size, swap_factor=0.1):
    """Generate a nearly sorted array by swapping some elements"""
    arr = list(range(size))
    num_swaps = int(size * swap_factor)
    for _ in range(num_swaps):
        i, j = random.randint(0, size-1), random.randint(0, size-1)
        arr[i], arr[j] = arr[j], arr[i]
    return arr

def generate_repeated_elements_array(size, unique_elements=10):
    """Generate an array with many repeated elements"""
    base = [random.randint(0, 10000) for _ in range(unique_elements)]
    return [random.choice(base) for _ in range(size)]

def generate_data_sets(sizes=[100, 1000, 10000]):
    """Generate various test data sets for different scenarios"""
    data_sets = {}
    
    for size in sizes:
        data_sets[f'random_{size}'] = generate_random_array(size)
        data_sets[f'sorted_asc_{size}'] = generate_sorted_array(size, True)
        data_sets[f'sorted_desc_{size}'] = generate_sorted_array(size, False)
        data_sets[f'nearly_sorted_{size}'] = generate_nearly_sorted_array(size)
        data_sets[f'repeated_{size}'] = generate_repeated_elements_array(size)
    
    return data_sets

if __name__ == "__main__":
    datasets = generate_data_sets()
    for name, data in datasets.items():
        print(f"Generated dataset: {name}, length: {len(data)}")